<?php
namespace Home\Model;
use Think\Model;
    class GoodsModel  extends Model {
           
      //根据查询条件显示相应商品
      public function getByFilter($field,$where)//查询的字段列表
        {
         //获取地址栏上的参数，SQL转义
          $filter=array_map(array($this->db,'escapeString'),I('get.'));
          $cid=$where['cid'];
          if(isset($filter['order']))
          {
               if ($filter['order']=='price_asc')
                   $order="price asc";
   
                if ($filter['order']=='price_desc')
           $order="price desc";
        
          }
          
           if(isset($filter['min_p']))
           {
              $where[]; 
           }
          //按条件查询
          $goodslist=$this->field($field)->where($where)->order($order)->select();
          return $goodslist; 
      }
        
    }


